package fan.project1_SpeedTalkSystem.Mapper;

import fan.project1_SpeedTalkSystem.Model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BlogMapper {

    @Select("select * from blog_info where delete_flag = 0 order by create_time desc ")
    public List<BlogInfo> selectAllBlogInfo();

    @Select("select * from blog_info where id =#{Id} and delete_flag = 0")
    public BlogInfo selectBlogInfoByid(int Id);

    @Insert("insert into blog_info(title,content,user_id) values(#{title},#{content},#{userId})")
    public Integer inserBlogInfo(BlogInfo blogInfo);

    public Integer updateBlogInfo(BlogInfo blogInfo);

    @Select("select user_id from blog_info where id =#{Id}")
    Integer getUserIdByBlogId(int Id);

    @Update("update blog_info set title = #{title} , content = #{content} where id = #{id}")
    Integer updateBlogByid(BlogInfo blogInfo);

    @Update("update blog_info set delete_flag = 1  where id = #{id}")
    Integer deleteBlogByid(int id);
}
